package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysClassHead;
import com.ruoyi.system.service.ISysClassHeadService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排课头Controller
 *
 * @author ruoyi
 * @date 2025-06-27
 */
@RestController
@RequestMapping("/system/class/head")
public class SysClassHeadController extends BaseController
{
    @Autowired
    private ISysClassHeadService sysClassHeadService;

    /**
     * 查询排课头列表
     */
    @PreAuthorize("@ss.hasPermi('system:head:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysClassHead sysClassHead)
    {
        startPage();
        List<SysClassHead> list = sysClassHeadService.selectSysClassHeadList(sysClassHead);
        return getDataTable(list);
    }

    /**
     * 导出排课头列表
     */
    @PreAuthorize("@ss.hasPermi('system:head:export')")
    @Log(title = "排课头", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysClassHead sysClassHead)
    {
        List<SysClassHead> list = sysClassHeadService.selectSysClassHeadList(sysClassHead);
        ExcelUtil<SysClassHead> util = new ExcelUtil<SysClassHead>(SysClassHead.class);
        util.exportExcel(response, list, "排课头数据");
    }

    /**
     * 获取排课头详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:head:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysClassHeadService.selectSysClassHeadById(id));
    }

    /**
     * 新增排课头
     */
    //@PreAuthorize("@ss.hasPermi('system:head:add')")
    @Log(title = "排课头", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SysClassHead sysClassHead)
    {
        return toAjax(sysClassHeadService.insertSysClassHead(sysClassHead));
    }

    /**
     * 修改排课头
     */
    @PreAuthorize("@ss.hasPermi('system:head:edit')")
    @Log(title = "排课头", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysClassHead sysClassHead)
    {
        return toAjax(sysClassHeadService.updateSysClassHead(sysClassHead));
    }

    /**
     * 删除排课头
     */
    @PreAuthorize("@ss.hasPermi('system:head:remove')")
    @Log(title = "排课头", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysClassHeadService.deleteSysClassHeadByIds(ids));
    }
}